// pages/recommend/components/choiceness/route/route.js
const http = require("../../../../../utils/http.js")
const utils = require("../../../../../utils/util.js")

Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    let that = this
    that.setData({
      routeId: options.routeId
    })
  },

  initData() {
    let that = this
    let routeId = that.data.routeId
    if (routeId == null) {
      return;
    }
    http.get("/route/getDetail", {
      routeId: routeId
    }).then(res => {
      let routeData = res.data.data;
      let startDayDate = utils.dateFormat(routeData.route.startDayDate)
      routeData.route.startDayDate = startDayDate
      for (let i = 0; i < routeData.routeDay.length; i++) {
        let date = utils.dateFormat(routeData.routeDay[i].routeDay.dayDate)
        routeData.routeDay[i].routeDay.dayDate = date
      }
      that.setData({
        route: routeData
      })
    })
  },
  bindtap(e){
    let poiId = e.currentTarget.dataset.poiid
    wx.navigateTo({
      url: '/pages/location/poidetail/poidetail?poiId=' + poiId,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    this.initData();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})